<?php
/**
* @package		EasyDiscuss
* @copyright	Copyright (C) 2010 Stack Ideas Private Limited. All rights reserved.
* @license		GNU/GPL, see LICENSE.php
* EasyDiscuss is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
*/
defined('_JEXEC') or die('Restricted access');

jimport( 'joomla.application.component.view');

require_once( DISCUSS_HELPERS . DS . 'date.php' );

class EasyDiscussViewCategories extends EasyDiscussView
{
	function display( $tmpl = null )
	{
		DiscussEventsHelper::importPlugin( 'content' );
		$mainframe	= JFactory::getApplication();
		$document	= JFactory::getDocument();
		$config 	= DiscussHelper::getConfig();
		$my         = JFactory::getUser();

		$sortConfig = $config->get('layout_sorting_category','latest');
		$sort		= JRequest::getCmd('sort',$sortConfig);

		$this->setPathway( JText::_( 'COM_EASYDISCUSS_BREADCRUMBS_CATEGORIES' ) );

		// @task: Add view
		$this->logView();

		$modelP				= $this->getModel( 'Posts' );
		$categoryModel		= $this->getModel( 'Categories' );

		$hideEmptyPost		= false;
		$categories			= $categoryModel->getCategoryTree();

		$theme	= new DiscussThemes();
		$theme->set( 'categories', $categories );

		echo $theme->fetch( 'categories.php' );
	}


	/*
	 * Show all the discussion in this category
	 */

	function listings()
	{
		$catId		= JRequest::getCmd('id','0');

		$mainframe	= JFactory::getApplication();
		$mainframe->redirect( DiscussRouter::_('index.php?option=com_easydiscuss&view=index&category_id='.$catId, false) );
		$mainframe->close();
	}
}
